<template>
  <div class="app_containers big">
    <moitorHeader></moitorHeader>
    <div class="bgc">
      <div class="bgc_a" >
        <div class="switchs"></div>
          <moitorSelect value="/smartMattress"></moitorSelect>
      </div>
      <div class="bgc_b">
        <rwSelect
          v-model:value="queryParams.wardId"
          type="ward"
          className="down_Box"
          :xhrParams="{ data: 'data' }"
          @input="changeWard"
          @loadList="loadList"
        ></rwSelect>
      </div>
      <!-- <div class="bgc_b">
        <a-select
          v-model="selectArea.types"
          :popper-append-to-body="false"
          @change="allRegions"
          dropdownClassName="down_Box"
        >
          <a-select-option label="默认排序 " value></a-select-option>
          <a-select-option
            v-for="item in selectArea"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></a-select-option>
        </a-select>
      </div> -->
    </div>
    <div class="m_main">
      <div class="box">
        <div class="contentSection">
          <div class="box_a" v-for="(item, id) of deviceList" :key="item.bedCode">
            <div class="left_content">
              <div class="left_content_top">{{ item.bedCode }}床</div>
              <span class="right_content_top">
                {{ com.handleName(item.memberName || "", "name") }}</span
              >
              <span class="right_content_top">{{ item.memberSexStr }}</span>
              <span class="right_content_top" v-show="item.memberAge"
                >{{ item.memberAge }}岁</span
              >
              <span class="right_content_top">{{ item.wardName }}</span>
            </div>
            <div class="right_content" v-show="item.isCheckIn && item.deviceCode">
              <div
                class="top_content"
                :class="[isAlarm(item, monitorWarStrings.HEART) ? 'warning' : '']"
              >
                <div class="left_content_heartRate code">心率</div>
                <div class="left_content_picture">
                  <span class="iconfont icon-xinlv code"></span>
                  <div class="left_content_value code">
                    {{ item.mattressHeartRate }} Bpm
                  </div>
                </div>
              </div>
              <div class="heartRate_module">
                <div class="right_content_heartRate">
                  {{ mattressTypeEnum[item.mattressStatus]?.text }}
                </div>
                <div class="right_content_picture">
                  <span
                    class="iconfont icon-weibiaoti-"
                    :style="{ color: mattressTypeEnum[item.mattressStatus]?.color }"
                  ></span>
                </div>
              </div>
              <div
                class="breathe_module"
                :class="[isAlarm(item, monitorWarStrings.BREATHE) ? 'warning' : '']"
              >
                <div class="right_content_breathe code">呼吸</div>
                <div class="right_breathe_picture">
                  <span class="iconfont icon-tubiao_- code"></span>
                  <div class="right_breathe_parameter code">{{ item.breathRate }}Bpm</div>
                </div>
              </div>
            </div>
            <p class="no_device" v-show="item.isCheckIn && !item.deviceCode">
              未&nbsp;&nbsp;绑&nbsp;&nbsp;定&nbsp;&nbsp;设&nbsp;&nbsp;备
            </p>
            <p class="no_device" v-show="!item.isCheckIn">空&nbsp;&nbsp;&nbsp;&nbsp;床</p>
          </div>
        </div>
        <moitorSlider :list="warning"></moitorSlider>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { monitorWarStrings } from "/@/enums/alarmTypeEnum";
import moitorSelect from "/@/components/monitor/monitorSelect.vue";
import { ref, onMounted, onUnmounted } from "vue";
import "../../../assets/iconfont/iconfont.css";
import { router } from "/@/router";
import moitorSlider from "/@/components/monitor/slider.vue";
import moitorHeader from "/@/components/monitor/header.vue";
import rwSelect from "/@/components/RW/orgSelect.vue";
import { mattressTypeEnum } from "/@/utils/type";
import { getList, getWarning } from "./index.api";
import { com } from "/@/utils/rw/common";
// const { exit , ins} = useBig()
getWarningList();
onUnmounted(() => {
  clearInterval(timer);
});
let timer = null;
const windowInstance: any = window;
const queryParams = ref({
  wardId: "",
});
const deviceList = ref([]);
const warning = ref([]);

const selectArea = ref({
  types: "",
});
function getWarningList() {
  getWarning({}).then((res) => {
    console.log(res, "res");
    warning.value = res.data;
  });
}
function isAlarm(item, type) {
  return item.warns.some((l) => type.includes(l.warnType));
}
function jump_millimeter() {
  router.push("/millimeterWaveRadar");
}
function allRegions() {
  console.log(123, "123");
}
function loadList(list) {
  queryParams.value.wardId = list[0].id;
  timer = setInterval(() => {
    obtainalarm();
  }, windowInstance.config.screen_time || 2000);
  obtainalarm();
}
function changeWard(id) {
  queryParams.value.wardId = id;
  obtainalarm();
}
//实时告警
function obtainalarm() {
  getList(queryParams.value).then((res) => {
    deviceList.value = res.data;
  });
}
</script>
<style lang="scss">
.code {
  transition: all 0.3s ease;
}
.warning {
  .code {
    color: red !important;
  }
}
.hide {
  width: 500px !important;
  overflow: auto;
  height: 30vh;
  background-color: #0f285a;
  border: 1px solid #1b60cc;

  .el-table {
    background-color: rgba(255, 255, 255, 0);
  }
  .el-table .el-table__header-wrapper th {
    border-bottom: 1px solid #618ee2;
    background-color: rgba(255, 255, 255, 0);
    color: #fff;
  }
  .el-table__empty-text {
    color: #fff;
  }
  .el-table tr {
    background-color: rgba(255, 255, 255, 0);

    color: #fff;
  }
  .el-table--enable-row-hover .el-table__body tr:hover > td.el-table__cell {
    background-color: #618ee2;
    border-bottom: 1px solid #618ee2;
  }
  .el-table td.el-table__cell {
    border-bottom: 1px solid #4e88df;
  }
  .el-table::before {
    background-color: rgba(255, 255, 255, 0);
  }
}
.mattressHidden {
  width: 500px !important;
  height: 30vh !important;
  overflow: auto !important;
  position: absolute !important;
  top: 754px !important;
  left: 330px !important;
  background-color: #0f285a;
  border: 1px solid #1b60cc;
  margin-top: -12%;
  margin-left: 50px !important;
  .el-table {
    background-color: rgba(255, 255, 255, 0);
  }
  .el-table .el-table__header-wrapper th {
    border-bottom: 1px solid #618ee2;
    background-color: rgba(255, 255, 255, 0);
    color: #fff;
  }
  .el-table__empty-text {
    color: #fff;
  }
  .el-table tr {
    background-color: rgba(255, 255, 255, 0);

    color: #fff;
  }
  .el-table--enable-row-hover .el-table__body tr:hover > td.el-table__cell {
    background-color: #618ee2;

    border-bottom: 1px solid #618ee2;
  }
  .el-table td.el-table__cell {
    border-bottom: 1px solid #4e88df;
  }
  .el-table::before {
    background-color: rgba(255, 255, 255, 0);
  }
}

.big {
  .ant-select-selection-item,
  .ant-empty-description {
    color: #01c3e8 !important;
    font-size: 14px;
  }
  .select {
    width: 100% !important;
  }
  .ant-select {
    width: 100% !important;
  }
  .ant-select-selection-placeholder {
    color: #01c3e8 !important;
    font-size: 14px;
  }
  .ant-select-selector {
    border: none !important;
    background: transparent !important;
    font-size: 18px;
    color: #01c3e8;
    width: 100% !important;
  }
}

.button_right_a {
  font-size: 18px;
  text-align: center;
  color: #01c3e8;
  margin-top: 20px;
  .ant-select-item-option-selected {
    background-color: #01c3e8 !important;
    color: #fff !important;
  }

  .ant-select-selection-item {
    font-size: 14px !important;
    color: #01c3e8 !important;
  }
  .ant-select-dropdown {
    background: transparent;
    border: solid 1px #1b60cc !important;
  }
  .ant-select-dropdown__item.hover {
    background: transparent;
  }
}
.down_Box {
  font-size: 18px;
  text-align: center;
  color: #01c3e8;
  width: 100%;
  border: solid 1px #1b60cc !important;
  background: transparent;
  .ant-select-item-option-content {
    color: #fff !important;
  }
  .ant-select-item:hover {
    background-color: #1b60cc;
  }
  .ant-select-item-option-selected {
    background-color: #01c3e8 !important;
    color: #fff !important;
  }

  .ant-select-selector {
    border: none !important;
    background: transparent !important;
    font-size: 18px;
    color: #ffffff;
  }
  .ant-select-item-option-active:not(.ant-select-item-option-disabled) {
    background-color: transparent;
  }
  .el-input__suffix > .el-input__suffix-inner > .a-select__caret {
    color: #01c3e8;
    font-size: 18px;
  }
}

.list_text {
  font-size: 18px;
  text-align: center;

  width: 100% !important;
  .ant-select-item {
    background: transparent;
    background-color: #12264b !important;
    color: #ddd7d7 !important;
  }

  .ant-select-selector {
    border: none;
    background: transparent;
    font-size: 18px;
    color: #01c3e8 !important;
    border: none !important;
    width: 100%;
    background: transparent !important;
  }
  .ant-select-selection-item {
    color: #01c3e8 !important;
  }

  .ant-select-item:hover {
    background-color: #1b60cc;
  }
  .ant-select-dropdown {
    position: absolute;
    top: 50px !important;
    left: 0px !important;
    background-color: #12264b;
    border: solid 1px #1b60cc !important;
  }
}
.jeecg-default-layout-main {
  margin-left: 0;
}
.jeecg-setting-drawer-fearure {
  display: none;
}
</style>
<style lang="scss" scoped>
.no_device {
  text-align: center;
  font-size: 25px;
  // letter-spacing: 15px;
  color: #01c3e8;
  line-height: 100px;
}
.app_containers {
  width: 100%;
  height: 100vh;
  background-image: url("../../../assets/ruijin/images/Underlay.png");
  background-size: 100% 100%;
  color: #fff;
  font-size: 12px;
  font-family: PingFangSC-Medium, PingFang SC, Microsoft YaHei;
  padding-bottom: 20px;
  .el-icon-back {
    font-size: 18px;
    text-align: center;
    font-family: TRENDS;
    margin-left: 20px;
  }
  .bgc {
    width: 100%;
    display: flex;
    .bgc_a {
      width: 230px;
      height: 30px;
      margin-left: 20px;
      margin-top: 30px;
      cursor: pointer;
      display: flex;
      background-color: #111(0, 0, 0, 0.1);
      border-radius: 25px 25px;
      box-shadow: 0px 0px 10px -2px rgb(247, 245, 245);
      .switchs {
        width: 28px;
        height: 20px;
        margin-left: 15px;
        background-repeat: no-repeat;
        display: inline-block;
        background-image: url("../../../assets/ruijin/images/jump.png");
        background-size: cover;
        margin-top: 5px;
      }
      .switch {
        line-height: 30px;
        font-size: 18px;
        font-family: TRENDS;
        margin-left: 15%;
      }
    }
  }

  .bgc_b {
    width: 190px;
    height: 30px;
    margin-left: 60px;
    margin-top: 30px;
    display: flex;
    background-color: #111(0, 0, 0, 0.1);
    border-radius: 25px 25px;
    box-shadow: 0px 0px 10px -2px rgb(247, 245, 245);
  }

  .m_main {
    padding: 0 !important;
    overflow: hidden;
    height: calc(100% - 90px);
    .box {
      width: 100%;
      height: 100%;
      display: flex;
      .contentSection {
        width: 80%;
        height: 100%;
        display: flex;
        flex-flow: wrap;
        overflow: auto;
        .box_a {
          width: 28%;
          height: 260px;
          margin-left: 5%;
          margin-top: 20px;
          max-width: 400px;
          margin-top: 20px;
          background-image: url("../../../assets/ruijin/images/border.png");
          background-repeat: no-repeat;
          background-size: 100% 100%;
          .left_content {
            width: 88%;
            height: 30%;
            margin-left: 12%;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
            .left_content_top {
              display: inline-block;
              margin-right: 20%;
              font-size: 24px;
              line-height: 90px;
            }
            .right_content_top {
              font-size: 15px;
              margin-left: 15px;
            }
            .left_content_heartRate {
              font-size: 14px;
              color: #fafafa;
              margin-left: 10%;
            }
          }
          //体征信息
          .right_content {
            width: 100%;
            height: 70%;
            display: flex;
            //心率
            .top_content {
              width: 33%;
              text-align: center;
              .left_content_heartRate {
                font-size: 15px;
              }
              .left_content_picture {
                margin-top: 15%;
                .iconfont {
                  font-size: 50px;
                  color: #1c9f83;
                }
                .left_content_value {
                  color: #fafafa;
                  margin-top: 24px;
                }
              }
            }
            //床垫
            .heartRate_module {
              width: 33%;
              text-align: center;
              .right_content_heartRate {
                font-size: 15px;
              }
              .right_content_picture {
                margin-top: 14%;
                .iconfont {
                  font-size: 60px;
                  color: #1c9f83;
                }
              }
            }
            //呼吸
            .breathe_module {
              width: 33%;
              text-align: center;
              .right_content_breathe {
                font-size: 15px;
              }
              .right_breathe_picture {
                margin-top: 15%;
                .iconfont {
                  font-size: 50px;
                  color: #1c9f83;
                }
                .right_breathe_parameter {
                  color: #fafafa;
                  margin-top: 24px;
                }
              }
            }
          }
        }
      }
    }
  }
}

// }
</style>
